import type { TbDevice } from "@/service/device";
import device from "@/service/device";
import { ref } from "vue";

export const globalDevices = ref<TbDevice[]>([]);
export const selectDevice = ref<TbDevice | null>(null);

export async function deviceUpdate() {
    globalDevices.value = await device.queryAll();
}

export async function deviceInit() {
    await deviceUpdate();
    if (globalDevices.value.length != 0) {
        selectDevice.value = globalDevices.value[0];
    }
}

